home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power Programmierung
/
Power-Programmierung (Tewi)(1994).iso
/
magazine
/
pctchnqs
/
1991
/
number3
/
dirsize.c
< prev
next >
Wrap
Text File
|
1991-06-13
|
1KB
|
46 lines
#include <direct.h>
#include <dos.h>
#include <stdio.h>
void listfile(struct ffblk *filedata);
struct ffblk filedata;
long numClusters = 0;
int disk = 4; /* drive A=1, B-2,... */
long BytesPerCluster(int drive);
unsigned int clusterSize;
main()
{ long total= 0 ;
clusterSize = BytesPerCluster(disk);
if (findfirst("*.exe", &filedata, FA_ARCH) == 0)
{
printf("The files in the current directory are ...\n\n");
listfile(&filedata);
total += filedata.ff_fsize;
while (findnext(&filedata) == 0)
{
listfile(&filedata);
total += filedata.ff_fsize;
}
printf(" Total = %ld numClusters = %ld clusterSize = %d\n",
total, numClusters, clusterSize);
printf(" Total disksize = %ld ", numClusters * clusterSize );
}
else perror("findfirst error");
}
void listfile(struct ffblk *filedata)
{
printf("%-14s %8ld %8ld\n",
(filedata->ff_name),
(filedata->ff_fsize),
((filedata->ff_fsize / clusterSize)+1 ));
numClusters += (filedata->ff_fsize / clusterSize)+1;
}
long BytesPerCluster(int drive)
{ union REGS regs;
struct SREGS sregs;
regs.h.ah = 0x1C; regs.h.dl = drive;
if (intdosx(®s, ®s, &sregs) != -1)
return( (long) regs.h.al * regs.x.cx );
}